Skip to content

Conversation

@QiWang19
Copy link
Member

@QiWang19 QiWang19 commented Nov 1, 2025

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Nov 1, 2025

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 1, 2025
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Nov 1, 2025

Hello @QiWang19! Some important instructions when contributing to openshift/api:
API design plays an important part in the user experience of OpenShift and as such API PRs are subject to a high level of scrutiny to ensure they follow our best practices. If you haven't already done so, please review the OpenShift API Conventions and ensure that your proposed changes are compliant. Following these conventions will help expedite the api review process for your PR.

@openshift-ci openshift-ci bot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Nov 1, 2025
@QiWang19 QiWang19 changed the title Add CRIOCredentialProviderConfig API and related functionality Add CRIOCredentialProviderConfig API Nov 1, 2025
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Nov 1, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign everettraven for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@QiWang19
Copy link
Member Author

QiWang19 commented Nov 1, 2025

/retest-required

@QiWang19 QiWang19 force-pushed the creds-provider branch 2 times, most recently from 8805169 to 108219f Compare November 3, 2025 22:49
@QiWang19
Copy link
Member Author

QiWang19 commented Nov 3, 2025

/test integration

@QiWang19 QiWang19 marked this pull request as ready for review November 3, 2025 23:26
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 3, 2025
@QiWang19
Copy link
Member Author

QiWang19 commented Nov 3, 2025

PR has been reviewed by claude code /api-review. It helped run make lint and correct the failures.


// +kubebuilder:validation:MaxLength=512
// +kubebuilder:validation:XValidation:rule=`self.matches('^((\\*|[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?)(\\.(\\*|[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?))*)(:[0-9]+)?(/[-a-zA-Z0-9_/]*)?$')`,message="invalid matchImages value, must be a valid fully qualified domain name with optional wildcard, port, and path"
type MatchImage string
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@saschagrunert PTAL. as mentioned in the previsou enhancement discussion(openshift/enhancements#1861 (comment)), this is a stricter rule than the upstream matchImages, as it does not allow wildcard matching of partial subdomains like app*.k8s.io. Customers may raise concerns about this difference, but it simplifies the configuration.
What do you think?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean, we can always make it looser later on while starting with a stricter regex. It's already fairly complex and we need extensive testing on that validation part.

The docs needs to be updated for this type, like:

// MatchImage is a string pattern used to match container image registry addresses.
// It must be a valid fully qualified domain name with optional wildcard, port, and path.
// The maximum length is 512 characters.
//
// Wildcards ('*') are supported for full subdomain labels and top-level domains.
// Each entry can optionally contain a port (e.g., :8080) and a path (e.g., /path).
// Wildcards are not allowed in the port or path portions.
//
// Examples:
// - "registry.io" - matches exactly registry.io
// - "*.azurecr.io" - matches any single subdomain of azurecr.io
// - "registry.io:8080/path" - matches with specific port and path prefix
//
// +kubebuilder:validation:MaxLength=512
// +kubebuilder:validation:XValidation:rule=`self.matches('^((\\*|[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?)(\\.(\\*|[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?))*)(:[0-9]+)?(/[-a-zA-Z0-9_/]*)?$')`,message="invalid matchImages value, must be a valid fully qualified domain name with optional wildcard, port, and path"
type MatchImage string


// +kubebuilder:validation:MaxLength=512
// +kubebuilder:validation:XValidation:rule=`self.matches('^((\\*|[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?)(\\.(\\*|[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?))*)(:[0-9]+)?(/[-a-zA-Z0-9_/]*)?$')`,message="invalid matchImages value, must be a valid fully qualified domain name with optional wildcard, port, and path"
type MatchImage string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean, we can always make it looser later on while starting with a stricter regex. It's already fairly complex and we need extensive testing on that validation part.

The docs needs to be updated for this type, like:

// MatchImage is a string pattern used to match container image registry addresses.
// It must be a valid fully qualified domain name with optional wildcard, port, and path.
// The maximum length is 512 characters.
//
// Wildcards ('*') are supported for full subdomain labels and top-level domains.
// Each entry can optionally contain a port (e.g., :8080) and a path (e.g., /path).
// Wildcards are not allowed in the port or path portions.
//
// Examples:
// - "registry.io" - matches exactly registry.io
// - "*.azurecr.io" - matches any single subdomain of azurecr.io
// - "registry.io:8080/path" - matches with specific port and path prefix
//
// +kubebuilder:validation:MaxLength=512
// +kubebuilder:validation:XValidation:rule=`self.matches('^((\\*|[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?)(\\.(\\*|[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?))*)(:[0-9]+)?(/[-a-zA-Z0-9_/]*)?$')`,message="invalid matchImages value, must be a valid fully qualified domain name with optional wildcard, port, and path"
type MatchImage string

Comment on lines 33 to 38
// status represents the current state of the CRIOCredentialProviderConfig.
// +optional
Status *CRIOCredentialProviderConfigStatus `json:"status,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional fields must explain what happens when they are omitted.

Suggested change
// status represents the current state of the CRIOCredentialProviderConfig.
// +optional
Status *CRIOCredentialProviderConfigStatus `json:"status,omitempty"`
// status represents the current state of the CRIOCredentialProviderConfig.
// When omitted or nil, it indicates that the status has not yet been set by the controller.
// The controller will populate this field with validation conditions and operational state.
// +optional
Status *CRIOCredentialProviderConfigStatus `json:"status,omitempty"`

Comment on lines 84 to 89
// conditions represent the latest available observations of the configuration state
// +optional
// +kubebuilder:validation:MaxItems=4
// +listType=map
// +listMapKey=type
Conditions []metav1.Condition `json:"conditions,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This field has three validation markers (MaxItems, listType, listMapKey) that must all be documented. The comment must explain:

  • behavior when omitted
  • the maximum of 4 items
  • that it's a map type keyed by type
  • what condition types are expected based on the constants defined in the file
Suggested change
// conditions represent the latest available observations of the configuration state
// +optional
// +kubebuilder:validation:MaxItems=4
// +listType=map
// +listMapKey=type
Conditions []metav1.Condition `json:"conditions,omitempty"`
// conditions represent the latest available observations of the configuration state.
// When omitted or empty, it indicates that no conditions have been reported yet.
// The maximum number of conditions is 4.
// Conditions are stored as a map keyed by condition type, ensuring uniqueness.
//
// Expected condition types include:
// - "Validated": indicates whether the matchImages configuration is valid
// +optional
// +kubebuilder:validation:MaxItems=4
// +listType=map
// +listMapKey=type
Conditions []metav1.Condition `json:"conditions,omitempty"`

Comment on lines 29 to 32
// spec defines the desired configuration of the CRIO Credential Provider.
// +required
Spec CRIOCredentialProviderConfigSpec `json:"spec,omitzero"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per API conventions, required fields should explicitly state in their documentation that they are required.

Suggested change
// spec defines the desired configuration of the CRIO Credential Provider.
// +required
Spec CRIOCredentialProviderConfigSpec `json:"spec,omitzero"`
// spec defines the desired configuration of the CRIO Credential Provider.
// This field is required and must be provided when creating the resource.
// +required
Spec CRIOCredentialProviderConfigSpec `json:"spec,omitzero"`

// passed to the kubelet CredentialProviderConfig, and if any pattern matches
// the requested image, CRI-O credential provider will be invoked to obtain credentials for pulling
// that image or its mirrors.
//
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're missing the docs for min and max items here, also that it refers to a set:

Suggested change
//
//
// This field is required and must contain between 1 and 50 entries.
// The list is treated as a set, so duplicate entries are not allowed.
//

Comment on lines 108 to 153
const (
// ConditionTypeValidated indicates whether the configuration is failed, or partially valid
ConditionTypeValidated = "Validated"

// ReasonValidationFailed indicates the MatchImages configuration contains invalid patterns
ReasonValidationFailed = "ValidationFailed"

// ReasonConfigurationPartiallyApplied indicates some matchImage entries were ignored due to conflicts
ReasonConfigurationPartiallyApplied = "ConfigurationPartiallyApplied"
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add comprehensive documentation about their meaning and usage:

Suggested change
const (
// ConditionTypeValidated indicates whether the configuration is failed, or partially valid
ConditionTypeValidated = "Validated"
// ReasonValidationFailed indicates the MatchImages configuration contains invalid patterns
ReasonValidationFailed = "ValidationFailed"
// ReasonConfigurationPartiallyApplied indicates some matchImage entries were ignored due to conflicts
ReasonConfigurationPartiallyApplied = "ConfigurationPartiallyApplied"
)
const (
// ConditionTypeValidated is a condition type that indicates whether the CRIOCredentialProviderConfig
// matchImages configuration has been validated successfully.
// When True, all matchImage patterns are valid and have been applied.
// When False, the configuration contains errors (see Reason for details).
// Possible reasons for False status:
// - ValidationFailed: matchImages contains invalid patterns
// - ConfigurationPartiallyApplied: some matchImage entries were ignored due to conflicts
ConditionTypeValidated = "Validated"
// ReasonValidationFailed is a condition reason used with ConditionTypeValidated=False
// to indicate that the matchImages configuration contains one or more invalid registry patterns
// that do not conform to the required format (valid FQDN with optional wildcard, port, and path).
ReasonValidationFailed = "ValidationFailed"
// ReasonConfigurationPartiallyApplied is a condition reason used with ConditionTypeValidated=False
// to indicate that some matchImage entries were ignored due to conflicts or overlapping patterns.
// The condition message will contain details about which entries were ignored and why.
ReasonConfigurationPartiallyApplied = "ConfigurationPartiallyApplied"
)

- Add feature gate for CRIOCredentialProviderConfig in various feature gate manifests.

Signed-off-by: Qi Wang <[email protected]>
@openshift-ci openshift-ci bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Nov 4, 2025
@QiWang19 QiWang19 changed the title Add CRIOCredentialProviderConfig API OCPNODE-3863: Add CRIOCredentialProviderConfig API Nov 4, 2025
@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Nov 4, 2025
@openshift-ci-robot
Copy link

openshift-ci-robot commented Nov 4, 2025

@QiWang19: This pull request references OCPNODE-3863 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.21.0" version, but no target version was set.

In response to this:

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci-robot
Copy link

openshift-ci-robot commented Nov 4, 2025

@QiWang19: This pull request references OCPNODE-3863 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.21.0" version, but no target version was set.

In response to this:

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Nov 4, 2025

@QiWang19: all tests passed!

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

}

const (

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit

Suggested change

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants